#ifndef WXSMENUEDITOR_H
#define WXSMENUEDITOR_H

#include <wx/treectrl.h>
#include <wx/sizer.h>
#include <wx/stattext.h>
#include <wx/textctrl.h>
#include <wx/checkbox.h>
#include <wx/statline.h>
#include <wx/radiobut.h>
#include <wx/panel.h>
#include <wx/button.h>
#include "wxsmenu.h"
#include "wxsmenuitem.h"

class wxsMenuBar;

class wxsMenuEditor: public wxPanel {
  public:
    wxsMenuEditor( wxWindow* parent, wxsMenuBar* MenuBar );
    wxsMenuEditor( wxWindow* parent, wxsMenu* Menu );
    virtual ~wxsMenuEditor();
    void ApplyChanges();
  private:
    typedef wxsMenuItem::Type Type;

    struct MenuItem {
      Type      m_Type;
      wxString  m_Variable;
      bool      m_IsMember;
      wxString  m_Id;
      wxString  m_Label;
      wxString  m_Accelerator;
      wxString  m_Help;
      wxsBitmapData m_Bitmap;
      wxString  m_ExtraCode;
      bool      m_Enabled;
      bool      m_Checked;
      wxString  m_HandlerFunction;
      MenuItem* m_Child;
      MenuItem* m_Next;
      MenuItem* m_Parent;
      wxTreeItemId m_TreeId;
    };
    class MenuItemHolder: public wxTreeItemData {
      public:
        MenuItemHolder( MenuItem* Item ): m_Item( Item ) {}
        virtual ~MenuItemHolder() {}
        MenuItem* m_Item;
    };
    void CreateContent( wxWindow* parent );
    void CreateDataCopy();
    void CreateDataCopyReq( wxsMenuBar* Bar, MenuItem* Parent );
    void CreateDataCopyReq( wxsMenu* Menu, MenuItem* Parent );
    void CreateDataCopyReq( wxsMenuItem* Menu, MenuItem* Parent );
    void StoreDataCopy();
    void StoreDataCopyReq( wxsParent* Parent, MenuItem* Item );
    void DeleteDataCopy();
    void DeleteDataCopyReq( MenuItem* Item );
    void UpdateMenuContent();
    void UpdateMenuContentReq( wxTreeItemId Id, MenuItem* Item );
    void CheckConsistency();
    void CheckConsistencyReq( MenuItem* Item );
    wxString GetItemTreeName( MenuItem* Item );
    void SelectItem( MenuItem* NewSelection );
    Type CorrectType( MenuItem* Item, bool& UseId, bool& UseLabel, bool& UseAccelerator, bool& UseHelp, bool& UseEnabled, bool& UseChecked );
    MenuItem* GetPrevious( MenuItem* Item );
    wxsMenuBar* m_MenuBar;
    wxsMenu* m_Menu;
    MenuItem* m_First;
    MenuItem* m_Selected;
    bool m_BlockSel;
    bool m_BlockRead;
    static const long ID_TREECTRL1;
    static const long ID_RADIOBUTTON1;
    static const long ID_RADIOBUTTON4;
    static const long ID_RADIOBUTTON2;
    static const long ID_RADIOBUTTON5;
    static const long ID_RADIOBUTTON3;
    static const long ID_STATICLINE1;
    static const long ID_STATICTEXT6;
    static const long ID_TEXTCTRL4;
    static const long ID_STATICTEXT1;
    static const long ID_TEXTCTRL1;
    static const long ID_STATICTEXT2;
    static const long ID_TEXTCTRL2;
    static const long ID_STATICTEXT3;
    static const long ID_TEXTCTRL3;
    static const long ID_STATICTEXT4;
    static const long ID_CHECKBOX1;
    static const long ID_STATICTEXT5;
    static const long ID_CHECKBOX2;
    static const long ID_STATICLINE2;
    static const long ID_BUTTON1;
    static const long ID_BUTTON2;
    static const long ID_BUTTON3;
    static const long ID_BUTTON4;
    static const long ID_BUTTON5;
    static const long ID_BUTTON6;
    void OnContentSelectionChanged( wxTreeEvent& event );
    void OnTypeChanged( wxCommandEvent& event );
    void OnButtonUpClick( wxCommandEvent& event );
    void OnButtonDownClick( wxCommandEvent& event );
    void OnButtonNewClick( wxCommandEvent& event );
    void OnButtonDelClick( wxCommandEvent& event );
    void OnButtonLeftClick( wxCommandEvent& event );
    void OnButtonRightClick( wxCommandEvent& event );
    void OnLabelChanged( wxCommandEvent& event );
    wxButton* Button4;
    wxStaticText* StaticText2;
    wxRadioButton* m_TypeNormal;
    wxButton* Button1;
    wxStaticText* StaticText6;
    wxTreeCtrl* m_Content;
    wxRadioButton* m_TypeRadio;
    wxStaticText* StaticText1;
    wxStaticText* StaticText3;
    wxCheckBox* m_Checked;
    wxButton* Button2;
    wxStaticLine* StaticLine2;
    wxButton* Button6;
    wxRadioButton* m_TypeCheck;
    wxRadioButton* m_TypeSeparator;
    wxButton* Button5;
    wxButton* Button3;
    wxStaticText* StaticText5;
    wxCheckBox* m_Enabled;
    wxStaticLine* StaticLine1;
    wxRadioButton* m_TypeBreak;
    wxStaticText* StaticText4;
    wxTextCtrl* m_Label;
    wxTextCtrl* m_Help;
    wxTextCtrl* m_Id;
    wxTextCtrl* m_Accelerator;
};

#endif
